{extend name="index/iframe" /}

{block name="content"}
<form class="layui-form layui-form-my" action="">
    <input type="hidden" name="cps_id" value="{$Think.get.cps_id}">
    <div class="layui-form-item">
        <div class="layui-block">
            <label class="layui-form-label">渠道类型</label>
            <div class="layui-input-block">
                <select name="cps_type" id="cps_type" class="layui-disabled" disabled lay-filter="cps_type" lay-verify="required">
                    <option value="">全部</option>
                    <optgroup label="CPS">
                        <option value="1" {$find.cps_type==1 ? 'selected' : ''}>CPS</option>
                        <option value="2" {$find.cps_type==2 ? 'selected' : ''}>代理</option>
                        <option value="4" {$find.cps_type==4 ? 'selected' : ''}>自有</option>
                    </optgroup>
                    <optgroup label="SDK">
                        <option value="3" {$find.cps_type==3 ? 'selected' : ''}>SDK</option>
                    </optgroup>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">渠道名称</label>
        <div class="layui-input-block">
            <input type="text" name="username" value="{$find.username}" id="username" lay-verify="required" placeholder="请输入渠道名称（中文）" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">登陆账号</label>
        <div class="layui-input-block">
            <input type="text" name="account" id="account" value="{$find.account}" lay-verify="required|account" placeholder="请输入渠道账号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">登陆密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" id="password" placeholder="为空不修改密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-block">
            <input type="password" name="password_confirm" id="password_confirm" placeholder="为空不修改密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">子渠道数量</label>
        <div class="layui-input-block">
            <input type="text" name="son_num" value="{$find.son_num}" id="son_num" lay-verify="required" placeholder="在渠道后台，渠道最多可添加子渠道的数量" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="intro" id="intro" placeholder="请输入渠道备注，可不填" class="layui-textarea">{$find.intro}</textarea>
        </div>
    </div>
    <div class="layui-form-item" style="margin-bottom: 100px;">
        <div class="layui-input-block">
            <button class="layui-btn my-btn" lay-submit="" lay-filter="submitBtn">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}

{block name="css"}
{/block}

{block name="js"}
<script>
    layui.use(['form', 'element'], function(){
        var form = layui.form
            ,$ = layui.$
            ,layer = layui.layer;

        console.dir({$Think.get.cps_id});
        if({$Think.get.cps_id}>=5000){ //如果是GM，显示GM回调
            $('#son_num').addClass('layui-disabled').attr('disabled', true);
        }else{
            $('#son_num').removeClass('layui-disabled').attr('disabled', false);
        }
        //提交
        form.on('submit(submitBtn)', function(data){
            var load = layer.load();
            $.post('{:url("ChannelAccount/edit")}',data.field, function(json){
                layer.close(load);
                json.code==0 ? layer.msg(json.msg, {icon: 1, time: 1000}) : layer.msg(json.msg, {icon: 0, time: 1000});
            }, 'JSON').error(function(){
                layer.close(load);
                layer.msg('连接超时，请联系后台管理员', {icon: 2, time:3000});
            });
            return false;
        });
    });
</script>
{/block}